import React from "react";
import { View, ViewPropTypes } from "react-native";
import IconFontAwesome from "react-native-vector-icons/FontAwesome";
import IconIonicons from "react-native-vector-icons/Ionicons";

const fontFamilies = { fontawesome: IconFontAwesome, ion: IconIonicons };

class TIcon extends React.Component {
  render() {
    const { name, style, size, color } = this.props;
    const [fontFamily, fontName] = name.split("|");
    const Icon = fontFamilies[fontFamily];
    return (
      <View style={[{ alignItems: "center", justifyContent: "center" }, style]}>
        <Icon name={fontName} size={size} color={color} />
      </View>
    );
  }
}

export default TIcon;
